import '@tarojs/async-await'
import Taro from '@tarojs/taro'
import Index from './pages/home'
import {Provider} from '@tarojs/redux'
import dva from './dva'
import models from './models'

import './app.less'

const dvaApp = dva.createApp({
  initialState: {},
  models: models,
  onError(e, dispatch) {
    // dispatch({
    //   type: 'projectCat/getAll',
    // });
  },
});
const store = dvaApp.getStore();

class App extends Taro.Component {

  config = {
    pages: [
      'pages/home/index',
      'pages/publish/index',
      'pages/pre_publish/index',
      'pages/my/index',
      'pages/favorite/index',
      'pages/webview/index',
      'pages/login/index',
      'pages/register/index',
      'pages/search_project/index',
      'pages/project_list/index',
      'pages/pca_for_query/index',
      'pages/project_detail/index',
      'pages/funding_detail/index',
      'pages/service_detail/index',
    ],
    window: {
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#8A9DEA',
      navigationBarTitleText: '沧石并购',
      navigationBarTextStyle: '#FFFFFF',
    },
    tabBar: {
      color: "#272636",
      selectedColor: "#8A9DEA",
      backgroundColor: "#FFFFFF",
      borderStyle: "#A8A8A8",
      list: [{
        pagePath: "pages/home/index",
        text: "首页",
        iconPath: "./assets/tab_bar_icon/home.png",
        selectedIconPath: "./assets/tab_bar_icon/home_selected.png"
      }, {
        pagePath: "pages/pre_publish/index",
        text: "发布",
        iconPath: "./assets/tab_bar_icon/publish.png",
        selectedIconPath: "./assets/tab_bar_icon/publish_selected.png"
      }, {
        pagePath: "pages/favorite/index",
        text: "关注",
        iconPath: "./assets/tab_bar_icon/favorite.png",
        selectedIconPath: "./assets/tab_bar_icon/favorite_selected.png"
      }, {
        pagePath: "pages/my/index",
        text: "我的",
        iconPath: "./assets/tab_bar_icon/my.png",
        selectedIconPath: "./assets/tab_bar_icon/my_selected.png"
      }]
    }
  }

  componentDidMount() {
    // dvaApp.dispatch({type: 'sys/test'})
  }

  componentDidShow() {
  }

  componentDidHide() {
  }

  componentCatchError() {
  }

  render() {
    return (<Provider store={store}>
      <Index/>
    </Provider>);
  }
}

Taro.render(<App/>, document.getElementById('app'))
